var Wb = {
	id : 0,
	get : Ext.getCmp,
	format : Ext.String.format,
	formatNum : Ext.util.Format.number,
	formatDate : Ext.Date.format,
	encode : Ext.encode,
	decode : Ext.decode,
	isEmpty : Ext.isEmpty,
	maxInt : 2147483647,
	space : "&nbsp;&nbsp;",
	dateFormat : "Y-m-d H:i:s.u",
	timeout : 30000,
	pageSize : 25,
	/*查找元素对象*/
	find : function(a) {
		if (Ext.isObject(a)) {
			return a
		} else {
			return Ext.getCmp(a)
		}
	},
	initialize : function(a, b) {
		window.Wd = window;
		Ext.BLANK_IMAGE_URL = "webbuilder/images/app/s.gif";
		Ext.QuickTips.init();
		if (a !== null) {
			if (a == -1) {
				a = Wb.maxInt
			}
			Wb.timeout = a;
			Ext.Ajax.timeout = a;
			Ext.data.JsonP.timeout = a;
			Ext.data.Connection.prototype.timeout = a;
			Ext.data.proxy.Server.prototype.timeout = a;
			Ext.form.Basic.prototype.timeout = Math.round(a / 1000)
		}
		Wb.zoneOffset = -b - (new Date()).getTimezoneOffset()
	},
	initTouch : function(a, b) {
		window.Wd = window;
		Wb.touchMode = true;
		if (window.LocalTouchLang) {
			LocalTouchLang()
		}
		if (a !== null) {
			if (a == -1) {
				a = Wb.maxInt
			}
			Wb.timeout = a
		}
		Wb.zoneOffset = -b - (new Date()).getTimezoneOffset()
	},
	checkEnter : function(d, h) {
		var g = Ext.EventObject, a = false;
		if (g.getKey() == g.ENTER) {
			if (h instanceof Ext.form.field.ComboBox) {
				a = true;
				if (h.isExpanded && h.picker.highlightedItem) {
					return
				}
			}
			d();
			if (a) {
				h.collapse()
			}
			g.stopEvent()
		}
	},
	dom : function(a) {
		return document.getElementById(a)
	},
	/*字符串转大写*/
	upper : function(a) {
		if (Wb.isEmpty(a)) {
			return ""
		} else {
			return a.toUpperCase()
		}
	},
	/*字符串转小写*/
	lower : function(a) {
		if (Wb.isEmpty(a)) {
			return ""
		} else {
			return a.toLowerCase()
		}
	},
	toLocal : function(a) {
		if (a) {
			return Ext.Date.add(a, Ext.Date.MINUTE, Wb.zoneOffset)
		} else {
			return a
		}
	},
	findRecord : function(b, d, e) {
		var a = null;
		b.each(function(f) {
			if (Wb.upper(f.get(d)) === Wb.upper(e)) {
				a = f;
				return false
			}
		});
		return a
	},
	/*json字符串转JSON对象*/
	decodeValue : function(a) {
		for ( var b in a) {
			a[b] = Wb.decode(a[b])
		}
	},
	numValidator : function(a) {
		if (Wb.isEmpty(a) || Ext.isNumeric(a)) {
			return true
		} else {
			return Wb.format(Str.invalidValue, a)
		}
	},
	tsValidator : function(a) {
		if (a == "") {
			return true
		}
		var b, d = [ "Y-m-d", "Y-n-j", "Y-m-d H:i:s", "Y-n-j H:i:s",
				"Y-m-d H:i:s.u", "Y-n-j H:i:s.u" ];
		for (b = 0; b < 6; b++) {
			if (Ext.Date.parse(a, d[b])) {
				return true
			}
		}
		return Wb.format(Str.invalidValue, a)
	},
	tmValidator : function(a) {
		if (a == "" || Ext.Date.parse(a, "H:i:s")) {
			return true
		} else {
			return Wb.format(Str.invalidValue, a)
		}
	},
	getBindValue : function(h, d) {
		if (Wb.isEmpty(d)) {
			return null
		}
		var i = h, g = i.displayField || i.valueField, e, a = undefined;
		(i.store.snapshot || i.store.data).each(function(b) {
			e = b.get(g);
			if (e === d) {
				a = b.get(i.valueField || i.displayField);
				return false
			}
		});
		return a
	},
	listValidator : function(a) {
		if (Ext.isEmpty(a) || Wb.getBindValue(this, a) !== undefined) {
			return true
		} else {
			return Wb.format(Str.invalidValue, a)
		}
	},
	isEmptyObj : function(a) {
		for ( var b in a) {
			return false
		}
		return true
	},
	promptWindow : null,
	promptValues : null,
	promptEditors : null,
	closePrompt : function() {
		if (Wb.promptWindow) {
			Wb.promptWindow.close();
			Wb.promptWindow = null
		}
	},
	prompt : function(m, a, f, h, n) {
		var g, k = [], e, d = a.length, l = 15, b;
		function o() {
			if (!Wb.verify(g)) {
				return
			}
			var s, q = Wb.promptEditors.length, t, p;
			Wb.promptValues = [];
			for (s = 0; s < q; s++) {
				t = Wb.promptEditors[s].getValue();
				Wb.promptValues.push(t ? t : "")
			}
			p = f(Wb.promptValues);
			if (!Ext.isDefined(p) || p) {
				if (h !== false) {
					g.close()
				}
			}
		}
		if (!n) {
			n = 105
		}
		for (e = 0; e < d; e++) {
			k.push({
				x : 1,
				y : l + 4,
				width : n,
				text : a[e].text + ":",
				xtype : "label",
				style : "text-align:right"
			});
			b = {
				x : n + 10,
				y : l,
				width : 375 - n,
				value : a[e].value,
				validator : a[e].validator,
				readOnly : a[e].readOnly,
				allowBlank : !Ext.isDefined(a[e].allowBlank) || a[e].allowBlank,
				listeners : {
					render : function() {
						Wb.promptEditors.push(this)
					}
				}
			};
			if (a[e].list) {
				Ext.apply(b, {
					typeAhead : true,
					xtype : "combo",
					queryMode : "local",
					triggerAction : "all",
					store : a[e].list,
					validator : a[e].validator || Wb.listValidator
				});
				if (Ext.isDefined(a[e].list[0].value)) {
					b.valueField = "value"
				}
			} else {
				b.xtype = "textfield"
			}
			if (b.readOnly) {
				b.fieldStyle = "background-color:#C0C0C0;background-image:none";
				b.selectOnFocus = true
			}
			k.push(b);
			l += 33
		}
		l += 67;
		if (l > 360) {
			l = 360
		}
		Wb.promptEditors = [];
		g = new Ext.window.Window({
			width : 430,
			height : l,
			title : m,
			layout : "absolute",
			modal : true,
			iconCls : "property_icon",
			resizable : false,
			autoScroll : true,
			buttons : [ {
				text : Str.ok,
				iconCls : "ok_icon",
				handler : function() {
					o()
				}
			}, {
				text : Str.cancel,
				iconCls : "cancel_icon",
				handler : function() {
					g.close()
				}
			} ],
			listeners : {
				render : function(i) {
					Wb.monEnter(i, o)
				}
			},
			items : k
		});
		g.show();
		Wb.promptEditors[0].focus(true, true);
		Wb.promptWindow = g
	},
	getTree : function(a) {
		if (a && a.boundView) {
			return Wb.get(a.boundView).ownerCt
		} else {
			return null
		}
	},
	getExcel : function(b, n, j) {
		var e = {}, f = [], i = Wb.find(b), q, h, o = i.store.proxy, d = new Ext.util.HashMap();
		function k() {
			var g, l, a = i.store.proxy.reader.getFields();
			for (g in a) {
				l = a[g];
				d.add(l.name, l.type ? l.type.type : "")
			}
		}
		function r(g, m) {
			var l, p, a;
			for (l in m) {
				p = m[l];
				if (j && p.hidden) {
					continue
				}
				if (p.type == "rowNumber") {
					e.xwl_numText = p.text == "&#160;" ? "" : p.text;
					e.xwl_numWidth = p.width
				} else {
					a = {
						align : p.align,
						dataIndex : p.dataIndex,
						format : p.excelFormat,
						ptFormat : p.printFormat,
						jsFormat : p.format,
						type : d.get(p.dataIndex),
						width : p.width,
						hidden : p.hidden,
						headerAlign : p.headerAlign,
						wrap : p.autoWrap,
						text : p.text == "&#160;" ? "" : p.text
					};
					if (p.items && p.items.length > 0) {
						a.columns = [];
						r(a.columns, p.items.items)
					}
					g.push(a)
				}
			}
			return g
		}
		q = i.store.proxy.reader.rawData;
		if (!q) {
			return
		}
		q = q.returnResult;
		if (q !== undefined) {
			Wb.message(Str.result + ": " + q);
			return
		}
		Ext.apply(e, o.allParams);
		e.xwl_url = o.url || o.api.read;
		e.xwl_dateformat = Ext.form.field.Date.prototype.format;
		e.xwl_timeformat = Ext.form.field.Time.prototype.format;
		e.xwl_thousandSeparator = Ext.util.Format.thousandSeparator;
		e.xwl_decimalSeparator = Ext.util.Format.decimalSeparator;
		e.xwl_sheet = i.exportSheetname;
		if (i.exportTitle == "-") {
			e.xwl_title = ""
		} else {
			e.xwl_title = i.exportTitle || i.title
		}
		e.xwl_file = i.exportFilename || e.xwl_title;
		e.xwl_feature = i.featureType;
		h = i.store.groupers.items;
		e.xwl_group = h.length > 0 ? h[0].property : "";
		k();
		e.xwl_meta = Wb.encode(r(f, i.columns));
		if (n) {
			e.start = 0;
			e.limit = Wb.maxInt
		}
		if (j) {
			Wb.submit("main?xwl=preview", e)
		} else {
			Wb.download("main?xwl=download", e)
		}
	},
	getPagingBar : function(b, h, i, m, a, l) {
		var k, j, f, d;
		if (b instanceof Ext.grid.Panel) {
			k = b.getDockedItems("pagingtoolbar");
			if (k.length > 0) {
				return k[0]
			} else {
				return null
			}
		}
		j = b && b.pageSize >= Wb.maxInt || b && b.buffered;
		k = [];
		if (a) {
			k.push({
				iconCls : "printer_icon",
				tooltip : Str.printCurrent,
				xtype : "splitbutton",
				handler : function() {
					Wb.getExcel(h, false, true)
				},
				menu : {
					xtype : "menu",
					items : [ {
						iconCls : "printer_icon",
						text : Str.printAll,
						handler : function() {
							Wb.getExcel(h, true, true)
						}
					} ]
				}
			})
		}
		if (i) {
			k.push({
				iconCls : "excel_icon",
				tooltip : Str.expCurToExcel,
				xtype : "splitbutton",
				handler : function() {
					Wb.getExcel(h, false)
				},
				menu : {
					xtype : "menu",
					items : [ {
						iconCls : "excel_icon",
						text : Str.expAllToExcel,
						handler : function() {
							Wb.getExcel(h, true)
						}
					} ,
					{//自定义导出 2014-6-9
						iconCls : "excel_icon",
						text : "自定义导出Excel",
						handler : function() {
							var p=Wb.find(h);
							var cols=Wb.find(h).columns;
							var o = Wb.find(h).store.proxy
							var col,idx,exportConfigStore,me=[];
							exportConfigStore=Ext.create('Ext.data.Store', {
							    fields:['columnName','dataIndex','otherName'],
							    data:[]
							    });
							for(idx in cols){
								col=cols[idx];
								if(col.type != "rowNumber"){
									var data=[{
									      'columnName':col.text == "&#160;" ? "" : col.text,
									      'dataIndex':col.dataIndex,
									      'otherName':''}];
									exportConfigStore.loadData(data,true);
								}
							}
							
							var exportExcelWin=new Ext.window.Window({
								id:"dataExportWin",title:"数据导出",height:372,width:463,layout:"absolute",closeAction:"hide",iconCls:"excel_icon",
								autoScroll:true,scroll:true,
								tbar:[
									{text:"导出文件名:",width:80,xtype:"label",style:"text-align:right"
									},
						            {id:"excelName",width:120,value:Wb.find(h).exportFilename,xtype:"textfield"
						            },
						            {text:",请勾选要导出的列名",width:150,xtype:"label",style:"text-align:left"
									}
						         ],
								okHandler:function(win){
									var selitems=exportConfigGrid.getSelectionModel().getSelection();
									if(selitems.length < 1){
										Wb.error('请选择要导出的列!');
										return false;
									}
									var dataType = new Ext.util.HashMap();
									var g, l, a = p.store.proxy.reader.getFields();
									for (g in a) {
										l = a[g];
										dataType.add(l.name, l.type ? l.type.type : "");
									}
									
									//获取表头
									function getMeta(meta, sis,oColumns) {
										var idx,selitem;
										if(sis){
											for(idx in sis){
												selitem=sis[idx];
												for(var ci in oColumns){
													if(selitem.data.dataIndex==oColumns[ci].dataIndex){
														var dataItem={
																align : oColumns[ci].align,
																dataIndex : selitem.data.dataIndex,
																format : oColumns[ci].excelFormat,
																ptFormat : oColumns[ci].printFormat,
																jsFormat : oColumns[ci].format,
																type : dataType.get(selitem.data.dataIndex),
																width : oColumns[ci].width,
																hidden : oColumns[ci].hidden,
																headerAlign : oColumns[ci].headerAlign,
																wrap : oColumns[ci].autoWrap,
																text : selitem.data.otherName == "" ? selitem.data.columnName : selitem.data.otherName
														};
														if(oColumns[ci].items && oColumns[ci].items.length > 0){
															dataItem.columns = [];
															getMeta(dataItem.columns,null,oColumns[ci].items.items);
														}
														meta.push(dataItem);
													}
												}
											}
										}else{
											for(var ci in oColumns){
												var dataItem={
														align : oColumns[ci].align,
														dataIndex : oColumns[ci].dataIndex,
														format : oColumns[ci].excelFormat,
														ptFormat : oColumns[ci].printFormat,
														jsFormat : oColumns[ci].format,
														type : dataType.get(oColumns[ci].dataIndex),
														width : oColumns[ci].width,
														hidden : oColumns[ci].hidden,
														headerAlign : oColumns[ci].headerAlign,
														wrap : oColumns[ci].autoWrap,
														text : oColumns[ci].text
												};
												if(oColumns[ci].items && oColumns[ci].items.length > 0){
													dataItem.columns = [];
													getMeta(dataItem.columns,null,oColumns[ci].items.items);
												}
												meta.push(dataItem);
											}
										}
										return meta;
									}
									var e = {};
									Ext.apply(e, o.allParams);
									e.xwl_url = o.url || o.api.read;
									e.start = 0;
									e.limit = Wb.maxInt;
									e.xwl_dateformat = Ext.form.field.Date.prototype.format;
									e.xwl_timeformat = Ext.form.field.Time.prototype.format;
									e.xwl_thousandSeparator = Ext.util.Format.thousandSeparator;
									e.xwl_decimalSeparator = Ext.util.Format.decimalSeparator;
									e.xwl_sheet = p.exportSheetname?p.exportSheetname:'';
									e.xwl_title = "";
									e.xwl_file = excelName.value?excelName.value:'';
									e.xwl_feature = p.featureType;
									var h = p.store.groupers.items;
									e.xwl_group = h.length > 0 ? h[0].property : "";
									e.xwl_meta = Wb.encode(getMeta(me, selitems,p.columns));
									Wb.download("main?xwl=download", e);
									win.hide();
								},
								buttons:Wb.winBtns(),
								modal:true,resizable:false,listeners:{
									afterrender:function(win,options){
										Wb.monEnter(this);
									},
									hide:function(win,options){
										win.destroy();
								}},items:[
								{id:"exportConfigGrid",region:"center",store:exportConfigStore,columnLines:true,xtype:"grid",columns:[
						          {id:"columnName",text:"列名",renderer:function(a,b){return Wb.rd(a,b,0,0)},width:160,
						            dataIndex:'columnName'
						          },
						          {id:"otherName",text:"导出别名",renderer:function(a,b){return Wb.rd(a,b,0,0)},width:160,
						            dataIndex:'otherName',editor:{xtype:"textfield"}
						          }
						          ],selModel:{checkOnly :true},selType:"checkboxmodel",
						         multiSelect:true,plugins:[{ptype:"cellediting",clicksToEdit:1}]
						        }
							]});
							Wb.edit(exportExcelWin);
							exportConfigGrid.getSelectionModel().selectAll();
						}
					}
					]
				}
			})
		}
		if (!j && m) {
			f = {
				click : function(e) {
					d = Wb.find(h);
					if (d.store) {
						d.store.pageSize = parseInt(e.text, 10);
						Wb.load(d.store)
					}
				}
			};
			k.push({
				iconCls : "page_icon",
				tooltip : Str.recordPerPage,
				menu : {
					xtype : "menu",
					minWidth : 80,
					listeners : {
						show : function(e) {
							if (b) {
								var g = [ 10, 25, 50, 100, 200, 500, 1000 ];
								g = Wb.indexOf(g, b.pageSize);
								if (g == -1) {
									Wb.uncheck(e)
								} else {
									e.items.items[g].setChecked(true)
								}
							}
						}
					},
					items : [ {
						group : "page",
						checked : false,
						text : "10",
						listeners : f
					}, {
						group : "page",
						checked : true,
						text : "25",
						listeners : f
					}, {
						group : "page",
						checked : false,
						text : "50",
						listeners : f
					}, {
						group : "page",
						checked : false,
						text : "100",
						listeners : f
					}, {
						group : "page",
						checked : false,
						text : "200",
						listeners : f
					}, {
						group : "page",
						checked : false,
						text : "500",
						listeners : f
					}, {
						group : "page",
						checked : false,
						text : "1000",
						listeners : f
					} ]
				}
			})
		}
		return {
			xtype : "pagingtoolbar",
			displayInfo : l,
			store : b,
			items : k,
			listeners : {
				render : function() {
					if (j) {
						var n = this.items.items, g, e = n.length;
						for (g = 0; g < 10; g++) {
							n[g].setVisible(false)
						}
						if (b && b.buffered) {
							n[13].setVisible(false);
							n[14].setVisible(false)
						}
					}
				}
			}
		}
	},
	uncheck : function(a) {
		if (a.items.length > 0) {
			a.items.items[0].setChecked(true);
			a.items.items[0].setChecked(false)
		}
	},
	getNode : function(b) {
		if (b.boundView) {
			var a = Wb.get(b.boundView).getTreeStore();
			return a.getNodeById(b.viewRecordId)
		} else {
			return null
		}
	},
	getDropedNode : function(a, e) {
		var d = Wb.getNode(a), b;
		if (e == "before") {
			b = d.previousSibling
		} else {
			if (e == "after") {
				b = d.nextSibling
			} else {
				b = d.lastChild
			}
		}
		return b
	},
	indexOf : function(f, d) {
		if (Ext.isEmpty(f)) {
			return -1
		}
		var e, b, a;
		if (Ext.isArray(f)) {
			e = f
		} else {
			e = f.split(",")
		}
		a = e.length;
		for (b = 0; b < a; b++) {
			if (e[b] === d) {
				return b
			}
		}
		return -1
	},
	getNamePart : function(b) {
		if (b == null) {
			return ""
		}
		var a = b.indexOf("=");
		if (a == -1) {
			return b
		} else {
			return b.substring(0, a)
		}
	},
	getValuePart : function(b) {
		if (b == null) {
			return ""
		}
		var a = b.indexOf("=");
		if (a == -1) {
			return ""
		} else {
			return b.substring(a + 1)
		}
	},
	login : function(d) {
		if (Wd.xwlw__x) {
			Wd.xwlw__x.hasVC = d;
			xwlw__x.win.show();
			return
		}
		Wd.xwlw__x = {
			hasVC : d
		};
		var a = Wd.xwlw__x, b;
		a.changeVC = function() {
			b = xwlw__x_img;
			if (b.isVisible()) {
				b.setSrc("main?xwl=13MC0NFI4FRE&" + Wb.getId())
			}
		};
		a.win = new Ext.window.Window(
				{
					width : 405,
					closeAction : "hide",
					buttons : [
							{
								id : "xwlw__x_lb",
								text : Str.login,
								iconCls : "accept_icon",
								xtype : "button",
								listeners : {
									click : function() {
										if (!Wb.verify(a.win)) {
											return
										}
										Wb
												.request({
													params : {
														username : xwlw__x_user
																.getValue(),
														password : xwlw__x_pwd
																.getValue(),
														verifyCode : xwlw__x_vc
																.getValue()
													},
													url : "main?xwl=13MC0NFI4FQE",
													failure : function(e, f) {
														a.changeVC()
													},
													failureConfirm : function(f) {
														var e = Wb
																.optString(f.responseText);
														if (e
																.indexOf(Str.invalidVc) != -1) {
															xwlw__x_vc.focus(
																	true, true)
														} else {
															if (e
																	.indexOf(Str.invalidPwd) != -1) {
																xwlw__x_pwd
																		.focus(
																				true,
																				true)
															} else {
																xwlw__x_user
																		.focus(
																				true,
																				true)
															}
														}
													},
													success : function() {
														Wb
																.setCookie(
																		"wb.pt.user",
																		xwlw__x_user
																				.getValue());
														a.win.hide()
													}
												})
									}
								}
							}, {
								text : Str.reset,
								iconCls : "refresh_icon",
								xtype : "button",
								listeners : {
									click : function() {
										Wb.reset(a.win);
										xwlw__x_user.focus(false, true)
									}
								}
							} ],
					iconCls : "key_icon",
					autoShow : false,
					title : Str.login,
					height : 247,
					layout : "absolute",
					buttonAlign : "center",
					listeners : {
						beforeshow : function(e) {
							var g = a.hasVC;
							xwlw__x_vl.setVisible(g);
							xwlw__x_vc.setVisible(g);
							if (g) {
								xwlw__x_img.setSrc("main?xwl=13MC0NFI4FRE&"
										+ Wb.getId())
							}
							xwlw__x_img.setVisible(g);
							xwlw__x_rfl.setVisible(g);
							e.setHeight(g ? 247 : 220)
						},
						render : function(e) {
							Wb.monEnter(e, function() {
								xwlw__x_lb.fireEvent("click")
							})
						},
						show : function() {
							var e = xwlw__x_user, g = Wb
									.getCookie("wb.pt.user");
							if (Wb.isEmpty(g)) {
								e.focus(false, 103)
							} else {
								e.setValue(g);
								xwlw__x_pwd.focus(false, 103)
							}
						},
						hide : function(e) {
							Wb.reset(e)
						}
					},
					items : [
							{
								src : "webbuilder/images/app/key.gif",
								y : 18,
								x : 64,
								xtype : "image",
								width : 48,
								height : 48
							},
							{
								text : Str.enterLogin,
								width : 200,
								x : 128,
								xtype : "label",
								y : 32 + 4
							},
							{
								text : Str.username + ":",
								width : 112,
								x : 8,
								xtype : "label",
								y : 80 + 4,
								style : "text-align:right"
							},
							{
								id : "xwlw__x_user",
								allowBlank : false,
								width : 224,
								y : 80,
								x : 128,
								xtype : "textfield"
							},
							{
								text : Str.password + ":",
								width : 112,
								x : 8,
								xtype : "label",
								y : 112 + 4,
								style : "text-align:right"
							},
							{
								id : "xwlw__x_pwd",
								allowBlank : false,
								inputType : "password",
								width : 224,
								y : 112,
								x : 128,
								xtype : "textfield"
							},
							{
								id : "xwlw__x_vl",
								text : Str.verifyCode + ":",
								width : 112,
								x : 8,
								xtype : "label",
								y : 144 + 4,
								style : "text-align:right"
							},
							{
								id : "xwlw__x_vc",
								maxLength : 5,
								allowBlank : false,
								minLength : 5,
								width : 64,
								y : 144,
								x : 128,
								xtype : "textfield"
							},
							{
								id : "xwlw__x_img",
								y : 145,
								x : 196,
								xtype : "image",
								width : 90,
								height : 20
							},
							{
								id : "xwlw__x_rfl",
								width : 56,
								html : '<a href="javascript:xwlw__x.changeVC()">'
										+ Str.change + "</a>",
								x : 296,
								xtype : "label",
								y : 144 + 4
							} ]
				});
		a.win.items.each(function(e) {
			Wd[e.id] = e
		});
		a.win.show()
	},
	message : function(d, b, a) {
		if (Wb.touchMode) {
			Ext.Msg.show({
				title : Str.information,
				message : d,
				buttons : Ext.MessageBox.OK,
				fn : b,
				iconCls : Ext.MessageBox.INFO
			})
		} else {
			Ext.Msg.show({
				title : Str.information,
				msg : d,
				buttons : Ext.Msg.OK,
				fn : b,
				icon : Ext.MessageBox.INFO,
				animateTarget : a
			})
		}
	},
	warning : function(d, b, a) {
		if (Wb.touchMode) {
			Ext.Msg.show({
				title : Str.warning,
				message : d,
				buttons : Ext.MessageBox.OK,
				fn : b,
				iconCls : Ext.MessageBox.WARNING
			})
		} else {
			Ext.Msg.show({
				title : Str.warning,
				msg : d,
				buttons : Ext.Msg.OK,
				fn : b,
				icon : Ext.MessageBox.WARNING,
				animateTarget : a
			})
		}
	},
	error : function(d, b, a) {
		if (Wb.touchMode) {
			Ext.Msg.show({
				title : Str.error,
				message : d,
				buttons : Ext.MessageBox.OK,
				fn : b,
				iconCls : Ext.MessageBox.ERROR
			})
		} else {
			Ext.Msg.show({
				title : Str.error,
				msg : d,
				buttons : Ext.Msg.OK,
				fn : b,
				icon : Ext.MessageBox.ERROR,
				animateTarget : a
			})
		}
	},
	except : function(g, f, e) {
		var a, d, b;
		if (Wb.isEmpty(g)) {
			a = Str.serverNotResp
		} else {
			d = g.indexOf("xwle__start");
			if (d > 0) {
				b = g.indexOf("xwle__end");
				a = g.substring(d + 18, b - 27)
			} else {
				d = g.indexOf("xwlw__login");
				if (d != -1) {
					if (Wb.touchMode) {
						Wb.submit("main?xwl=tlogin", {
							xwlhref : Wb.encode(window.location.href)
						}, "_self")
					} else {
						Wb.login(g.indexOf("xwlw__needLV=true") != -1)
					}
					return
				} else {
					a = g
				}
			}
		}
		Wb.error(a, f, e)
	},
	confirm : function(b, a, e, d) {
		if (Wb.touchMode) {
			Ext.Msg.show({
				title : Str.confirm,
				message : b,
				buttons : Ext.MessageBox.OKCANCEL,
				iconCls : Ext.MessageBox.QUESTION,
				fn : function(f) {
					if (f == "ok") {
						a()
					}
				}
			})
		} else {
			if (b instanceof Ext.grid.Panel) {
				Wb.confirmGrid(b, a, e, d)
			} else {
				Ext.Msg.show({
					title : Str.confirm,
					msg : b,
					buttons : Ext.Msg.OKCANCEL,
					icon : Ext.MessageBox.QUESTION,
					animateTarget : e,
					fn : function(f) {
						if (f == "ok") {
							a()
						}
					}
				})
			}
		}
	},
	confirmGrid : function(d, f, b, h) {
		var g = Wb.getSelRec(d), a = g.length, e;
		if (a == 0) {
			Wb.warning(Str.selValid);
			return
		}
		if (h == null) {
			h = Str.deleteStr.toLowerCase()
		}
		if (a == 1 && b) {
			e = Wb.format(Str.actionConfirm, h, g[0].get(b))
		} else {
			e = Wb.format(Str.actionSelConfirm, h, a)
		}
		Wb.confirm(e, f)
	},
	choose : function(d, b, a) {
		if (Wb.touchMode) {
			Ext.Msg.show({
				title : Str.confirm,
				message : d,
				buttons : Ext.MessageBox.YESNOCANCEL,
				fn : b,
				iconCls : Ext.MessageBox.QUESTION
			})
		} else {
			Ext.Msg.show({
				title : Str.confirm,
				msg : d,
				buttons : Ext.Msg.YESNOCANCEL,
				fn : b,
				icon : Ext.MessageBox.QUESTION,
				animateTarget : a
			})
		}
	},
	wait : function(a, b) {
		Ext.Msg.show({
			msg : a || Str.processing,
			width : 300,
			wait : true,
			waitConfig : {
				interval : 500
			},
			animateTarget : b
		})
	},
	progress : function(d, a, b) {
		if (d == 0) {
			Ext.Msg.show({
				msg : a || Str.processing,
				progressText : "0%",
				width : 300,
				progress : true,
				closable : false,
				animateTarget : b
			})
		} else {
			Ext.MessageBox.updateProgress(d, Math.round(100 * d) + "%")
		}
	},
	focus : function(b, a) {
		setTimeout(function() {
			if (b.win && !b.sourceEditMode) {
				b.getWin().focus()
			} else {
				b.textareaEl.focus()
			}
			b.activated = true;
			if (a) {
				a()
			}
		}, 50)
	},
	setModified : function(a) {
		if (!a.isModified) {
			a.isModified = true;
			a.setTitle("*" + a.title)
		}
	},
	delModified : function(a) {
		if (a.isModified) {
			a.isModified = false;
			a.setTitle(a.title.substring(1))
		}
	},
	optString : function(a) {
		if (Wb.isEmpty(a)) {
			return ""
		} else {
			return a
		}
	},
	optNum : function(a) {
		return parseFloat(a) || 0
	},
	mask : function(b, d) {
		var a = d || Str.processing;
		if (Wb.touchMode) {
			if (!Ext.Viewport.maskCount) {
				Ext.Viewport.mask({
					xtype : "loadmask",
					indicator : true,
					message : a
				});
				Ext.Viewport.maskCount = 0
			}
			Ext.Viewport.maskCount++
		} else {
			if (b = Wb.find(b)) {
				b = b.el;
				if (!b.maskCount) {
					b.mask(a);
					b.maskCount = 0
				}
			} else {
				b = Ext.getBody();
				if (!b.maskCount) {
					a = b.mask(a);
					b.maskCount = 0;
					if (a.getWidth() == 0 || a.getHeight() == 0) {
						a.dom.style.width = "100%";
						a.dom.style.height = "100%"
					}
					a.setStyle("zIndex", 90000);
					a.next().setStyle("zIndex", 90001)
				}
			}
			b.maskCount++
		}
	},
	maskBody : function(a) {
		Wb.mask(null, a)
	},
	unmask : function(a) {
		if (Wb.touchMode) {
			if (Ext.Viewport.maskCount) {
				Ext.Viewport.maskCount--
			}
			if (!Ext.Viewport.maskCount) {
				Ext.Viewport.unmask()
			}
		} else {
			if (a) {
				a = Wb.find(a).el
			} else {
				a = Ext.getBody()
			}
			if (a.maskCount) {
				a.maskCount--
			}
			if (!a.maskCount) {
				a.unmask()
			}
		}
	},
	isEditor : function(a) {
		return a.tagName == "INPUT" && a.type == "text"
				|| a.tagName == "TEXTAREA"
	},
	getRootNode : function(a) {
		var b = a;
		while (b.getDepth() > 0) {
			b = b.parentNode
		}
		return b
	},
	verifyName : function(b) {
		var e, d, a = b.length;
		for (d = 0; d < a; d++) {
			e = b.charAt(d);
			if (!(e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e == "_" || d > 0
					&& (e >= "0" && e <= "9"))) {
				return Wb.format(Str.invalidName, b)
			}
		}
		return true
	},
	getVerifyFunc : function(a, b) {
		return function(e) {
			var d = a, h = b, g, f = d.length;
			if (h) {
				h = Str.invalidName
			} else {
				h = Str.invalidValue
			}
			for (g = 0; g < f; g++) {
				if (e.indexOf(d[g]) != -1) {
					return Wb.format(h, e)
				}
			}
			return true
		}
	},
	isAcross : function(f, g) {
		var e, d = f.length;
		var b, a = g.length;
		for (e = 0; e < d; e++) {
			if (!Wb.isEmpty(f[e])) {
				for (b = 0; b < a; b++) {
					if (f[e] == g[b]) {
						return true
					}
				}
			}
		}
		return false
	},
	toItemId : function(d, a) {
		if (d.id) {
			delete d.id
		} else {
			return d
		}
		if (a) {
			d.itemId = a
		}
		function b(g) {
			var f, e;
			if (g.items) {
				for (f in g.items) {
					e = g.items[f];
					e.itemId = e.id;
					delete e.id;
					b(e)
				}
			}
		}
		b(d);
		return d
	},
	setDDText : function(a, b) {
		a.getPlugin("ddPlug").dragZone.dragText = b
	},
	getIconCls : function(b, a) {
		if (Wb.isEmpty(a)) {
			a = ""
		} else {
			a = ' title="' + a + '"'
		}
		return '<img class="wb_icon ' + b
				+ '" src="webbuilder/images/app/s.gif"' + a + ">"
	},
	getIcon : function(b, a) {
		if (Wb.isEmpty(a)) {
			a = ""
		} else {
			a = ' title="' + a + '"'
		}
		return '<img class="wb_icon" src="' + b + '"' + a + ">"
	},
	dateRender : function(a) {
		if (a) {
			return Wb.dateToStr(a,
					Ext.Date.format(a, "Hisu") === "000000000" ? false : null)
		} else {
			return ""
		}
	},
	timeRender : function(a) {
		if (a) {
			return Wb.dateToStr(a, true)
		} else {
			return ""
		}
	},
	downRender : function(a) {
		return function(f, e, h, g) {
			return Wb.isEmpty(f) ? "(blob)"
					: "<a href='javascript:downloadBlob(\"" + a + '",' + g
							+ ")'>" + f + "</a>"
		}
	},
	winBtns : function() {
		return [ {
			text : Str.ok,
			iconCls : "ok_icon",
			handler : Wb.okHandle
		}, {
			text : Str.cancel,
			iconCls : "cancel_icon",
			handler : Wb.cancelHandle
		} ]
	},
	rd : function(e, b, d, g) {
		if (d) {
			b.style = "white-space:normal;"
		}
		if (g) {
			var a = Ext.util.Format;
			if (g.indexOf("0") == -1) {
				return a.date(e, g)
			} else {
				return a.number(e, g)
			}
		} else {
			if (Ext.isDate(e)) {
				return Wb.dateRender(e)
			}
		}
		return e === null ? "" : Ext.htmlEncode(e)
	},
	nr : function(h, g, o, l, k, i) {
		g.tdCls = "x-grid-cell-special";
		var j = i.currentPage, m = o.get("__rowNum");
		if (m) {
			return (j > 0 ? j - 1 : 0) * i.pageSize + m
		} else {
			return i.indexOfTotal(o) + 1
		}
	},
	htmlRender : function(a) {
		return Ext.htmlEncode(a)
	},
	setCookie : function(a, b) {
		Ext.util.Cookies.set(a, b, Ext.Date.add(new Date(), Ext.Date.MONTH, 1))
	},
	getCookie : function(a) {
		return Ext.util.Cookies.get(a)
	},
	removeSel : function(b) {
		Wb.remove(b, false, true)
	},
	remove : function(f, e, n) {
		if (!f) {
			return
		}
		var l, h, g, d, m;
		if (f instanceof Ext.grid.Panel) {
			d = f.getSelectionModel();
			m = d.getSelection();
			h = f.store;
			l = h.indexOf(m[0]);
			if (e) {
				h.removeAll()
			} else {
				h.remove(m)
			}
			g = h.getCount() - 1;
			if (l > g) {
				l = g
			}
			if (l > -1) {
				f.getView().select(l)
			}
			if (!n) {
				Wb.refresh(f, m.length * -1)
			}
		} else {
			h = f.length;
			for (l = h - 1; l >= 0; l--) {
				if (f[l] && (f[l] === e || n && f[l][n] === e[n])) {
					f.splice(l, 1)
				}
			}
		}
	},
	showNavMenu : function(l, f, i) {
		var g, k, j, h, a, e;
		if (!l.tabItems) {
			return
		}
		if (i) {
			a = l
		} else {
			a = f
		}
		l.menu = l.saveMenu;
		if (!l.menu) {
			l.menu = Ext.create("Ext.menu.Menu")
		}
		l.menu.removeAll();
		h = l.tabItems.length;
		for (j = h - 1; j >= 0; j--) {
			k = l.tabItems[j];
			e = k instanceof Ext.data.Model;
			if (e) {
				g = k.get("iconCls");
				if (!k.isLeaf()) {
					g = "folder_icon"
				}
			} else {
				g = k.iconCls
			}
			l.menu.add({
				text : e ? k.get("text") : k.title,
				handler : function(n) {
					var d, b = l.saveMenu.items.indexOf(n) + 1, m;
					if (!f.tabItems) {
						f.tabItems = []
					}
					m = f.tabItems;
					m.push(a.saveLastTab);
					for (d = 0; d < b; d++) {
						m.push(l.tabItems.pop())
					}
					m.pop();
					while (m.length > 10) {
						m.shift()
					}
					a.stopRecNav = true;
					if (e) {
						n.tabItem.ownerTree.getView().select(n.tabItem)
					} else {
						Wb.show(n.tabItem)
					}
					a.stopRecNav = false;
					a.saveLastTab = n.tabItem
				},
				tabItem : k,
				iconCls : g
			})
		}
		l.showMenu();
		l.saveMenu = l.menu;
		l.menu = null;
		delete l.menu
	},
	closeNav : function(a, e, b) {
		b.stopRecNav = true;
		Wb.remove(a.tabItems, b, "id");
		Wb.remove(e.tabItems, b, "id")
	},
	clearNav : function(a, b) {
		a.tabItems = [];
		b.tabItems = []
	},
	recNav : function(f, e, a) {
		a.tbChanged = true;
		if (!f || !e || a.stopRecNav || e.stopRecNav) {
			return
		}
		a.saveLastTab = f;
		if (!a.tabItems) {
			a.tabItems = []
		}
		var d = a.tabItems;
		if (d.length > 9) {
			d.shift()
		}
		d.push(e)
	},
	navBack : function(a, d) {
		a.tbChanged = false;
		Wb.navBackOn(a, d);
		if (!a.tbChanged) {
			Wb.navBackOn(a, d)
		}
	},
	navFwd : function(a, d) {
		a.tbChanged = false;
		Wb.navFwdOn(a, d);
		if (!a.tbChanged) {
			Wb.navFwdOn(a, d)
		}
	},
	navBackOn : function(d, h) {
		var g = d.tabItems, e, a;
		if (!g || g.length == 0) {
			return
		}
		e = g.pop();
		if (!h.tabItems) {
			h.tabItems = []
		}
		a = h.tabItems;
		if (a.length > 9) {
			a.shift()
		}
		a.push(d.saveLastTab);
		d.stopRecNav = true;
		if (e instanceof Ext.data.Model) {
			e.ownerTree.getView().select(e)
		} else {
			Wb.show(e)
		}
		d.stopRecNav = false;
		d.saveLastTab = e
	},
	navFwdOn : function(d, h) {
		var g = h.tabItems, e, a;
		if (!g || g.length == 0) {
			return
		}
		e = g.pop();
		a = d.tabItems;
		if (a.length > 9) {
			a.shift()
		}
		a.push(d.saveLastTab);
		d.stopRecNav = true;
		if (e instanceof Ext.data.Model) {
			e.ownerTree.getView().select(e)
		} else {
			Wb.show(e)
		}
		d.stopRecNav = false;
		d.saveLastTab = e
	},
	setStore : function(a) {
		if (Wb.touchMode) {
			if (a.isLoading()) {
				return false
			}
			a.getProxy().setExtraParams(
					Ext.apply({}, a.params, Wb.getValue(a.output)))
		} else {
			if (!(a instanceof Ext.data.TreeStore) && a.isLoading()) {
				return false
			}
			Ext.apply(a.proxy.extraParams, a.params, Wb.getValue(a.output))
		}
		return true
	},
	loadPage : function(b, a, d) {
		if (b) {
			if (d) {
				if (!b.params) {
					b.params = {}
				}
				Ext.apply(b.params, d)
			}
			b.loadPage(a)
		}
	},
	load : function(a, b) {
		Wb.loadPage(a, 1, b)
	},
	reload : function(a, b) {
		Wb.loadPage(a, a.currentPage, b)
	},
	mapKey : function(a, d) {
		var b;
		for (b in d) {
			if (d[b][0] == a) {
				return d[b][1]
			}
		}
		return a
	},
	verifyObj : function(d, b) {
		var a = b, e;
		if (d instanceof Ext.form.field.Base && !d.hidden && !d.disabled
				&& !d.validate() && !a) {
			a = d
		}
		if ((d instanceof Ext.container.AbstractContainer)
				&& !(d instanceof Ext.form.CheckboxGroup)) {
			d.items.each(function(f) {
				e = Wb.verifyObj(f, a);
				if (e && !a) {
					a = e
				}
			})
		}
		return a
	},
	show : function(e) {
		var d = e, f = e, a = [];
		while (d = d.ownerCt) {
			if (d instanceof Ext.tab.Panel) {
				a.push(f)
			}
			f = d
		}
		while (d = a.pop()) {
			d.ownerCt.setActiveTab(d)
		}
	},
	verify : function(f) {
		var e = Wb.getList(f), g, d, b = e.length, a = null;
		for (d = 0; d < b; d++) {
			g = Wb.verifyObj(e[d], null);
			if (g && !a) {
				a = g
			}
		}
		if (a) {
			Wb.show(a);
			a.focus(true, true);
			return false
		} else {
			return true
		}
	},
	okHandle : function() {
		var a = this.up("window");
		if (a.okHandler) {
			a.okHandler(a)
		}
	},
	cancelHandle : function() {
		var a = this.up("window");
		if (a.closeAction == "hide") {
			a.hide()
		} else {
			a.close()
		}
	},
	toBottom : function(a) {
		a.body.dom.scrollTop = a.body.dom.scrollHeight
	},
	monEnter : function(e, d) {
		if (e.okHandler || d) {
			var a = e.getKeyMap(), b;
			a.on(13, function() {
				if (e.el.isMasked() || Ext.getBody().isMasked()) {
					return
				}
				b = Ext.EventObject.target;
				if (b && b.type == "textarea") {
					return
				}
				if (d) {
					d(e)
				} else {
					e.okHandler(e)
				}
				Ext.EventObject.stopEvent()
			})
		}
	},
	strToDate : function(a) {
		if (a.indexOf(".") == -1) {
			return Ext.Date.parse(a, "Y-m-d H:i:s")
		} else {
			return Ext.Date.parse(a, Wb.dateFormat)
		}
	},
	toString : function(a) {
		if (a) {
			return Ext.Date.format(a, Wb.dateFormat)
		} else {
			return ""
		}
	},
	dateToStr : function(d, a) {
		if (Wb.isEmpty(d)) {
			return ""
		}
		var e = Ext.form.field.Date.prototype.format, b = Ext.form.field.Time.prototype.format;
		if (a === true) {
			e = b
		} else {
			if (a !== false) {
				e += " " + b
			}
		}
		if (!Ext.isDate(d)) {
			d = Wb.strToDate(d)
		}
		return Ext.Date.format(d, e)
	},
	delNodeConfirm : function(a, d, b) {
		var e = Wb.getSelNode(a);
		if (e && (!b || e != a.getRootNode())) {
			Wb.confirm(Wb.format(Str.delConfirm, e.get("text")), d)
		} else {
			Wb.warning(Str.selValid)
		}
	},
	delSelNode : function(a) {
		var b = Wb.getSelNode(a);
		if (b) {
			if (b.nextSibling) {
				a.view.select(b.nextSibling)
			} else {
				if (b.previousSibling) {
					a.view.select(b.previousSibling)
				} else {
					if (b.getDepth() > 0
							&& (b.rootVisible || b.parentNode != a
									.getRootNode())) {
						a.view.select(b.parentNode)
					} else {
						a.selModel.deselectAll()
					}
				}
			}
			b.remove()
		}
	},
	getSelNode : function(a, b) {
		var d = a.getSelectionModel().getSelection();
		if (d && d.length > 0) {
			return d[0]
		}
		return b ? a.getRootNode() : null
	},
	getSelRec : function(a) {
		return a.getSelectionModel().getSelection()
	},
	saveNodePos : function(a) {
		a.savePos = {
			p : a.parentNode,
			s : a.nextSibling
		}
	},
	revertNodePos : function(a) {
		var b = a.savePos;
		if (b.s) {
			b.p.insertBefore(a, b.s)
		} else {
			b.p.appendChild(a)
		}
	},
	sort : function(a) {
		a.sort(function(d, b) {
			if (Ext.isString(d) && Ext.isString(b)) {
				return d.toUpperCase().localeCompare(b.toUpperCase())
			} else {
				return d > b ? 1 : (d < b ? -1 : 0)
			}
		});
		return a
	},
	setTitle : function(a, d) {
		var e = a.title, b = e.indexOf(" - ");
		if (b != -1) {
			e = e.substring(0, b)
		}
		if (Wb.isEmpty(d)) {
			a.setTitle(e)
		} else {
			a.setTitle(e + " - " + d)
		}
	},
	ellipsis : function(h, g) {
		var m, e, d = h.length, b = 0, a = 0, f;
		for (e = 0; e < d; e++) {
			m = h.charCodeAt(e);
			if (m < 128) {
				b++
			} else {
				b += 2
			}
			a++;
			if (b > 20) {
				break
			}
		}
		f = a > d - 4 ? h : (h.substring(0, a) + "...");
		if (g) {
			return Ext.htmlEncode(f)
		} else {
			return f
		}
	},
	open : function(a, h, d, g, e) {
		var f = window, b = window.top;
		while (f != b && !f.WBXwlOpen) {
			f = f.parent
		}
		if (f && f.WBXwlOpen && !Wb.isEmpty(h)) {
			f.WBXwlOpen(a, h, d, g, e)
		} else {
			Wb.submit(a, g, null, e)
		}
	},
	isLogout : function() {
		var a = window.top;
		return a && a.Pt && a.Pt.canLogout
	},
	print : function(b) {
		var d = Wd, a = d.top;
		while (d != a && !d.WBXwlPrint) {
			d = d.parent
		}
		if (d && d.WBXwlPrint) {
			d.WBXwlPrint(b)
		}
	},
	println : function(a) {
		Wb.print(a + "\n")
	},
	getList : function(d) {
		var b = [];
		if (Ext.isArray(d)) {
			b = d
		} else {
			if (Ext.isObject(d)) {
				b.push(d)
			} else {
				var e, a = d.split(",");
				for (e in a) {
					b.push(Wb.get(Ext.String.trim(a[e])))
				}
			}
		}
		return b
	},
	getId : function() {
		if (Wb.id === 0) {
			Wb.id = (new Date()).getTime()
		}
		return Wb.id++
	},
	request : function(h, i) {
		var g, e = {}, a = h.showResult, b = h.showMask !== false, d = h.scope
				|| window;
		if (h.beforerequest && h.beforerequest.call(d, h) === false) {
			return
		}
		Ext.copyTo(e, h, [ "async", "disableCaching", "headers", "scope",
				"url", "withCredentials" ]);
		e.method = h.method || "POST";
		if (h.form) {
			e.form = Wb.get(h.form).getForm();
			e.isUpload = true
		}
		e.params = Ext.apply({}, i);
		Ext.apply(e.params, h.params, Wb.getValue(h.output));
		if (h.timeout === -1) {
			e.timeout = Wb.maxInt
		} else {
			if (h.timeout) {
				e.timeout = h.timeout
			}
		}
		e.callback = function(j, f, k) {
			if (b) {
				Wb.unmask(h.mask)
			}
			if (h.callback) {
				h.callback.call(d, j, f, k)
			}
			if (f) {
				if (h.input) {
					Wb.setValue(Wb.decode(k.responseText))
				}
				if (h.success) {
					h.success.call(d, k, j)
				}
				if (a || h.result) {
					Wb.message(h.result || Str.operCompleted, function() {
						g = h.successConfirm;
						if (g) {
							g.call(d, k, j)
						}
					})
				}
			} else {
				if (h.failure) {
					h.failure.call(d, k, j)
				}
				if (a !== false) {
					Wb.except(k.responseText, function() {
						g = h.failureConfirm;
						if (g) {
							g.call(d, k, j)
						}
					})
				}
			}
		};
		if (b) {
			Wb.mask(h.mask, h.message)
		}
		h.ajaxObject = Ext.Ajax.request(e)
	},
	edit : function(d, g, k, f) {
		var h = d instanceof Ext.grid.Panel, i;
		if (k && h) {
			i = g;
			var a = Wb.getSelRec(d), e = d.store.model.prototype.fields, j = {};
			if (a.length != 1) {
				Wb.warning(Str.selRec);
				return
			}
			a = a[0];
			d.selRec = a;
			e.each(function(b) {
				j[b.name] = a.get(b.name)
			});
			Wb.setValue(j);
			i.setTitle(f ? k : (Str.edit + " - " + j[k]))
		} else {
			if (h) {
				i = g
			} else {
				i = d
			}
			//i.setTitle(Str.newStr)
		}
		i.isNew = k == null;
		i.show()
	},
	setButton : function(a) {
		var b = Ext.fly(a.id + "-btnEl");
		if (b) {
			if (a.bgImage) {
				b.setStyle("background-image", 'url("' + a.bgImage + '")')
			} else {
				b.setStyle("background-image", "none")
			}
			if (a.bgColor) {
				b.setStyle("background-color", a.bgColor)
			}
		}
	},
	convert : function(a) {
		if (Wb.isEmpty(a)) {
			return ""
		} else {
			if (Ext.isBoolean(a)) {
				return a ? 1 : 0
			} else {
				if (Ext.isDate(a)) {
					return Ext.Date.toString(a)
				} else {
					if (Ext.isFunction(a)) {
						return Wb.convert(a())
					} else {
						if (Ext.isObject(a) || Ext.isArray(a)) {
							return Wb.encode(a)
						} else {
							return a
						}
					}
				}
			}
		}
	},
	save : function(k, i) {
		var g = i || k.getValue(), j = k.displayField, b = k.valueField, h, f = k.store, a = {};
		if (!g) {
			return
		}
		f.clearFilter();
		h = k.findRecord(j || b, g);
		if (h) {
			f.remove(h)
		}
		if (j) {
			a[j] = g
		}
		if (b && b !== j) {
			a[b] = g
		}
		f.insert(0, a);
		if (f.getCount() > 100) {
			f.removeAt(100)
		}
		k.collapse()
	},
	like : function(h) {
		var f, a = h.combo, g = h.query, i = new RegExp(".*" + g + ".*"), d = a.displayField
				|| a.valueField;
		a.store.filterBy(function(b) {
			f = b.get(d);
			return i.test(f)
		});
		if (a.store.getCount() > 0) {
			a.expand();
			a.doAutoSelect()
		} else {
			a.collapse()
		}
		return false
	},
	reportError : function(g, f) {
		try {
			var h, j = f.contentWindow.document || f.contentDocument
					|| window.frames[f.id].document;
			if (j) {
				if (j.body) {
					h = Wb.decode(j.body.innerHTML);
					if (!h.success) {
						Wb.except(Ext.htmlDecode(h.value))
					}
				}
			}
		} catch (i) {
			Wb.error(Str.serverNotResp)
		}
	},
	getFrame : function() {
		if (!Wb.frame) {
			var a = document.createElement("iframe"), b = "xf_" + Wb.getId();
			Ext.fly(a).set({
				id : b,
				name : b,
				cls : Ext.baseCSSPrefix + "hide-display",
				src : Ext.SSL_SECURE_URL
			});
			document.body.appendChild(a);
			if (document.frames) {
				document.frames[b].name = b
			}
			Ext.fly(a).on("load", Wb.reportError);
			Wb.frame = a
		}
		return Wb.frame
	},
	getForm : function(e, a) {
		var g, f = "xwlgform", b, d = Wb.dom(f);
		if (d) {
			while (d.childNodes.length !== 0) {
				d.removeChild(d.childNodes[0])
			}
		} else {
			d = document.createElement("FORM");
			d.setAttribute("name", f);
			d.setAttribute("id", f);
			document.body.appendChild(d)
		}
		if (e) {
			for (g in e) {
				b = document.createElement("input");
				b.setAttribute("name", g);
				b.setAttribute("type", "hidden");
				b.setAttribute("value", Wb.convert(e[g]));
				d.appendChild(b)
			}
		}
		if (a) {
			d.encoding = "multipart/form-data"
		} else {
			d.encoding = "application/x-www-form-urlencoded"
		}
		return d
	},
	getChart : function(a) {
		Wb.download("main?xwl=13NUIG6TAFSD", {
			data : Ext.draw.engine.SvgExporter.self.generate({}, a.surface),
			file : "chart.svg"
		}, true)
	},
	submit : function(b, g, f, d, a) {
		var e = Wb.getForm(g, a);
		e.action = b;
		e.method = d || "POST";
		e.target = f || "_blank";
		e.submit()
	},
	download : function(d, f, a) {
		var b = Wb.getFrame(), e = Wb.getForm(f, a);
		e.action = d + "&_xwlfm=1";
		e.method = "POST";
		e.target = b.id;
		e.submit()
	},
	upload : function(d, e) {
		var d = Wb.find(d), a = d.showResult, o, m, i, f = d.showMask !== false, j = a !== false, n = "", l;
		if (d.beforerequest && d.beforerequest.call(d, d) === false) {
			return
		}
		if (d.showProgress) {
			f = false;
			Wb.progressId = Wb.getId();
			n = "&__uploadId=" + Wb.progressId;
			Wb.progress(0);
			Wb.progressTimer = setInterval(function() {
				if (l) {
					return
				}
				l = 1;
				Ext.Ajax.request({
					url : "main?xwl=progress",
					timeout : 6000,
					params : {
						progressId : Wb.progressId
					},
					callback : function() {
						l = 0
					},
					success : function(b) {
						if (Wb.progressTimer !== null) {
							i = Wb.decode(b.responseText).value;
							if (i > 0) {
								Wb.progress(i)
							}
						}
					}
				})
			}, 1000)
		}
		if (f) {
			Wb.mask(d.maskControl, d.message)
		}
		function h() {
			if (d.showProgress) {
				if (Wb.progressTimer !== null) {
					clearInterval(Wb.progressTimer);
					Wb.progressTimer = null
				}
			}
		}
		d
				.getForm()
				.submit(
						{
							params : Ext.apply(Ext.apply({}, Wb.getValue(d), Wb
									.getValue(d.output)), d.params, e),
							url : d.url + "&_xwlfm=1" + n,
							success : function(g, b) {
								h();
								if (f) {
									Wb.unmask(d.maskControl)
								}
								if (a || d.result) {
									Wb.message(d.result || Str.operCompleted)
								} else {
									if (d.showProgress) {
										Ext.MessageBox.hide()
									}
								}
								m = d.success;
								if (b.result == null) {
									Wb.warning(Str.serverNotResp)
								} else {
									if (m) {
										b.result.value = Ext
												.htmlDecode(b.result.value);
										m(g, b, b.result.value)
									}
								}
							},
							failure : function(g, b) {
								h();
								if (f) {
									Wb.unmask(d.maskControl)
								}
								if (j && !b.result) {
									Wb.error(Str.serverNotResp);
									return
								}
								b.result.value = Ext.htmlDecode(b.result.value);
								o = b.result.value;
								if (j) {
									Wb.except(o)
								} else {
									if (d.showProgress) {
										Ext.MessageBox.hide()
									}
								}
								m = d.failure;
								if (m) {
									m(g, b, o)
								}
							}
						})
	},
	clearGrid : function(a) {
		var d = Wb.find(a), b = d.store;
		d.headerCt.removeAll();
		b.removeAll();
		b.sorters.clear()
	},
	setGrid : function(b, a) {
		var d = Wb.find(b);
		if (!d.columns || d.columns.length == 0) {
			d.reconfigure(a, a.proxy.reader.rawData.columns)
		}
	},
	getVal : function(a) {
		var b;
		if (Ext.isObject(a)) {
			b = a.id
		} else {
			b = a
		}
		return Wb.getValue(a, true)[b]
	},
	getTouchValue : function(k, d) {
		if (Wb.isEmpty(k)) {
			return {}
		}
		var f, e = {}, b, a, i, l, j, h;
		function g(n) {
			a = n.id;
			h = n._itemId;
			i = null;
			j = true;
			if (n instanceof Ext.field.Radio) {
				i = n.getGroupValue()
			} else {
				if (n instanceof Ext.field.Checkbox) {
					i = n.isChecked() ? 1 : 0
				} else {
					if (n instanceof Ext.field.Hidden) {
						i = n._xvalue
					} else {
						if (n instanceof Ext.dataview.DataView) {
							i = Wb
									.encode(Wb.getRows(n,
											n.outputType === "all"))
						} else {
							if (n instanceof Ext.field.Select) {
								var m = n.record;
								i = (m && m.isModel) ? m.get(n
										.getDisplayField()) : "";
								if (a && a.indexOf("-") == -1) {
									e[a + "_text"] = i
								} else {
									if (h && h.indexOf("-") == -1) {
										e[h + "_text"] = i
									}
								}
								i = n.getValue()
							} else {
								if (n instanceof Ext.field.Field) {
									i = n.getValue()
								} else {
									j = false
								}
							}
						}
					}
				}
			}
			if (j) {
				if (a && a.indexOf("-") == -1) {
					e[a] = i
				} else {
					if (h && h.indexOf("-") == -1) {
						e[h] = i
					}
				}
			}
			if (!d && (n instanceof Ext.Container)) {
				n.items.each(function(o) {
					g(o, e)
				})
			}
		}
		f = Wb.getList(k);
		for (b in f) {
			g(f[b], e)
		}
		return e
	},
	getValue : function(l, e) {
		if (Wb.touchMode) {
			return Wb.getTouchValue(l, e)
		}
		if (Wb.isEmpty(l)) {
			return {}
		}
		var g, f = {}, d, b, j, m, k, i, a;
		function h(n) {
			b = n.id;
			i = n.itemId;
			j = null;
			k = true;
			if (n instanceof Ext.form.field.Checkbox) {
				j = n.getValue() ? 1 : 0
			} else {
				if (n instanceof Ext.form.CheckboxGroup) {
					j = Wb.getIndex(n)
				} else {
					if (n instanceof Ext.form.field.Hidden) {
						j = n.xvalue
					} else {
						if (n instanceof Ext.slider.Single) {
							j = n.getValue()
						} else {
							if (n instanceof Ext.form.field.Base
									|| n instanceof Ext.ux.form.field.DateTime
									|| n instanceof Ext.form.field.HtmlEditor) {
								if (n instanceof Ext.form.field.File) {
									k = false
								} else {
									a = n instanceof Ext.form.field.ComboBox;
									if (a) {
										if (n.inputEl) {
											j = n.inputEl.dom.value
										} else {
											j = ""
										}
										if (b && b.indexOf("-") == -1) {
											f[b + "_text"] = j
										} else {
											if (i && i.indexOf("-") == -1) {
												f[i + "_text"] = j
											}
										}
									}
									if (n.forceList && a) {
										j = Wb.getBindValue(n,
												n.inputEl ? n.inputEl.dom.value
														: "")
									} else {
										j = n.getValue()
									}
								}
							} else {
								if (n instanceof Ext.grid.Panel) {
									j = Wb.encode(Wb.getRows(n,
											n.outputType === "all"))
								} else {
									k = false
								}
							}
						}
					}
				}
			}
			if (k) {
				if (b && b.indexOf("-") == -1) {
					f[b] = j
				} else {
					if (i && i.indexOf("-") == -1) {
						f[i] = j
					}
				}
			}
			if (!e && (n instanceof Ext.container.AbstractContainer)
					&& !(n instanceof Ext.form.FieldContainer)) {
				n.items.each(function(o) {
					h(o, f)
				})
			}
		}
		g = Wb.getList(l);
		for (d in g) {
			h(g[d], f)
		}
		return f
	},
	setVal : function(d, b) {
		var e, a = {};
		if (Ext.isObject(d)) {
			e = d.id
		} else {
			e = d
		}
		a[e] = b;
		Wb.setValue(a)
	},
	reset : function(e) {
		var b = Wb.getList(e), g, f, h, a;
		for (h in b) {
			g = b[h];
			if (g) {
				f = g.id;
				if (f) {
					a = {};
					a[f] = "";
					Wb.setValue(a, true);
					if (Wb.touchMode) {
						if (g instanceof Ext.Container) {
							g.items.each(function(d) {
								if (d.id && d.id.indexOf("-") == -1) {
									Wb.reset(d)
								}
							})
						}
					} else {
						if ((g instanceof Ext.container.AbstractContainer)
								&& !(g instanceof Ext.form.CheckboxGroup)) {
							g.items.each(function(d) {
								Wb.reset(d)
							})
						}
					}
				}
			}
		}
	},
	setTouchValue : function(d, b) {
		var f, a, e;
		for (f in d) {
			e = Wb.get(f);
			if (!e) {
				continue
			}
			a = d[f];
			if (e instanceof Ext.field.Radio) {
				if (b) {
					e.reset()
				} else {
					e.setGroupValue(a)
				}
			} else {
				if (e instanceof Ext.field.Checkbox) {
					if (b) {
						e.reset()
					} else {
						e.setChecked(a === 1 || a === true || a === "on"
								|| a === "1")
					}
				} else {
					if (e instanceof Ext.field.Hidden) {
						if (b) {
							e._xvalue = null
						} else {
							e._xvalue = a
						}
					} else {
						if (e instanceof Ext.field.DatePicker) {
							if (b) {
								e.reset()
							} else {
								if (Wb.isEmpty(a)) {
									e.setValue("")
								} else {
									if (Ext.isString(a)) {
										a = Wb.strToDate(a)
									}
									e.setValue(a)
								}
							}
						} else {
							if (e instanceof Ext.dataview.DataView) {
								if (b) {
									if (e.getStore()) {
										e.getStore().removeAll()
									}
								}
							} else {
								if (e instanceof Ext.field.Field) {
									if (b) {
										e.reset()
									} else {
										e.setValue(a)
									}
								}
							}
						}
					}
				}
			}
		}
	},
	setValue : function(d, b) {
		if (Wb.touchMode) {
			Wb.setTouchValue(d, b);
			return
		}
		var f, a, e;
		for (f in d) {
			e = Wb.get(f);
			if (!e) {
				continue
			}
			a = d[f];
			if (e instanceof Ext.form.CheckboxGroup) {
				if (b) {
					if (!(e instanceof Ext.form.RadioGroup)) {
						Wb.setIndex(e, null)
					}
				} else {
					Wb.setIndex(e, a)
				}
			} else {
				if (e instanceof Ext.form.field.Hidden) {
					if (b) {
						e.xvalue = null
					} else {
						e.xvalue = a
					}
				} else {
					if (e instanceof Ext.slider.Single) {
						if (b) {
							e.setValue(e.minValue || 0)
						} else {
							e.setValue(a)
						}
					} else {
						if (e instanceof Ext.form.field.Checkbox) {
							if (b) {
								e.reset()
							} else {
								e.setValue(a === 1 || a === true || a === "on"
										|| a === "1")
							}
						} else {
							if (e instanceof Ext.form.field.Date
									|| e instanceof Ext.form.field.Time
									|| e instanceof Ext.ux.form.field.DateTime) {
								if (b) {
									e.reset()
								} else {
									if (Wb.isEmpty(a)) {
										e.setValue("")
									} else {
										if (Ext.isString(a)) {
											a = Wb.strToDate(a)
										}
										e.setValue(a)
									}
								}
							} else {
								if (e instanceof Ext.form.field.Base
										|| e instanceof Ext.form.field.HtmlEditor) {
									if (b) {
										e.reset()
									} else {
										e.setValue(a)
									}
								} else {
									if (e instanceof Ext.grid.Panel) {
										if (b && e.store) {
											e.store.removeAll()
										}
									} else {
										if (e instanceof Ext.tree.Panel) {
											if (b) {
												Wb.check(e, false, false, true)
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	},
	getIndex : function(l) {
		var e, d, h, g, f;
		if (l instanceof Ext.grid.Panel) {
			e = l.getSelectionModel().getSelection();
			if (e.length > 0) {
				return l.store.indexOf(e[0])
			}
		} else {
			if (l instanceof Ext.form.CheckboxGroup) {
				e = l.getBoxes();
				d = l instanceof Ext.form.RadioGroup;
				f = [];
				g = e.length;
				for (h = 0; h < g; h++) {
					if (d) {
						if (e[h].getValue()) {
							return h
						}
					} else {
						f.push(e[h].getValue() ? 1 : 0)
					}
				}
				if (!d) {
					return f
				}
			}
		}
		return -1
	},
	setIndex : function(g, f) {
		var a = g.getBoxes(), e, d;
		if (g instanceof Ext.form.RadioGroup) {
			a[f].setValue(true)
		} else {
			e = a.length;
			for (d = 0; d < e; d++) {
				a[d].setValue(f != null && f[d])
			}
		}
	},
	insert : function(b, a, d) {
		return Wb.insertValue(b, Wb.getValue(a), d)
	},
	insertValue : function(b, k, e) {
		var d, h, n = b.store, g = n.proxy.reader.getFields(), j = {}, l, a, m;
		for (d in g) {
			h = g[d];
			m = k[h.name];
			if (m === undefined) {
				m = null
			}
			j[h.name] = m
		}
		if (Ext.isNumber(e)) {
			l = e;
			e = true
		} else {
			l = Wb.getIndex(b)
		}
		if (e === true && l == -1 || e == null) {
			n.insert(0, j);
			l = 0
		} else {
			if (e === true) {
				n.insert(l, j)
			} else {
				l = n.getCount();
				n.insert(l, j)
			}
		}
		b.getSelectionModel().select(l);
		a = n.getAt(l);
		if (n.getCount() > n.pageSize) {
			if (e === false) {
				n.removeAt(0)
			} else {
				n.removeAt(n.pageSize)
			}
		}
		Wb.refresh(b, 1);
		return a
	},
	update : function(e, d) {
		return Wb.updateValue(e, Wb.getValue(d))
	},
	updateRecord : function(f, e) {
		var d = f.store, a = d.model.prototype.fields, b;
		a.each(function(g) {
			b = e[g.name];
			if (b !== undefined) {
				f.set(g.name, b)
			}
		});
		f.commit()
	},
	updateValue : function(e, g) {
		var d = e.store, a = d.model.prototype.fields, f = Wb.getSelRec(e)[0], b;
		a.each(function(h) {
			b = g[h.name];
			if (b !== undefined) {
				f.set(h.name, b)
			}
		});
		f.commit();
		return f
	},
	toHtml : function(g, a) {
		if (Wb.isEmpty(g)) {
			if (a) {
				return "&nbsp;"
			} else {
				return ""
			}
		}
		var f, e = g.length, d = [];
		for (f = 0; f < e; f++) {
			c = g.charAt(f);
			switch (c) {
			case " ":
				d.push("&nbsp;");
				break;
			case '"':
				d.push("&quot;");
				break;
			case "<":
				d.push("&lt;");
				break;
			case ">":
				d.push("&gt;");
				break;
			case "&":
				d.push("&amp;");
				break;
			case "\n":
				d.push("<br>");
				break;
			case "\r":
				break;
			case "\t":
				d.push("&nbsp;&nbsp;&nbsp;&nbsp;");
				break;
			default:
				d.push(c)
			}
		}
		return d.join("")
	},
	setMenu : function(a, b) {
		if (!a.bindedPPMenu) {
			a.on("contextmenu", function(d) {
				b.showAt(d.getXY());
				d.preventDefault()
			});
			a.bindedPPMenu = true
		}
	},
	saveOrigin : function(a) {
		a.store.each(function(b) {
			b.__origin = Ext.apply({}, b.data);
			b.__isNew = undefined
		})
	},
	getRows : function(d, a) {
		var e, b = [];
		if (Wb.touchMode) {
			if (a) {
				d.getStore().each(function(f) {
					b.push(f.data)
				})
			} else {
				e = d.getSelection();
				Ext.Array.each(e, function(f) {
					b.push(f.data)
				})
			}
		} else {
			if (a) {
				d.store.each(function(f) {
					b.push(f.data)
				})
			} else {
				e = Wb.getSelRec(d);
				Ext.Array.each(e, function(f) {
					b.push(f.data)
				})
			}
		}
		return b
	},
	selFirst : function(a) {
		var b;
		if (a instanceof Ext.tree.Panel) {
			if (!a.xwlFirstSel) {
				b = a.getRootNode();
				if (!a.rootVisible) {
					b = b.firstChild
				}
				if (b) {
					a.view.select(b);
					a.xwlFirstSel = true
				}
			}
		} else {
			if (a instanceof Ext.grid.Panel) {
				if (a.store && a.store.getCount() > 0) {
					a.getSelectionModel().select(0)
				}
			}
		}
	},
	refresh : function(h, g, f) {
		var e, d, j, i;
		if (h instanceof Ext.tree.Panel) {
			if (h.xwlRefresh) {
				return
			}
			h.xwlRefresh = 1;
			if (!g) {
				g = "text"
			}
			d = Wb.getSelNode(h, true);
			e = d.getPath(g, "\n");
			h.selModel.deselectAll();
			i = h.getRootNode();
			h.store.load({
				callback : function(a, k, b) {
					if (h.xwlRefresh) {
						delete h.xwlRefresh
					}
					if (b) {
						h.selectPath(e, g, "\n", function(m, l) {
							if (!m) {
								if (h.rootVisible) {
									h.getSelectionModel().select(i)
								} else {
									if (i.firstChild) {
										h.getSelectionModel().select(
												i.firstChild)
									}
								}
							}
							if (f) {
								f(m, l)
							}
						})
					}
				}
			})
		} else {
			if (h instanceof Ext.grid.Panel) {
				j = h.store;
				if (j.getCount() == 0) {
					Wb.loadPage(j, Math.max(j.currentPage - 1, 1))
				} else {
					e = Wb.getPagingBar(h);
					if (e) {
						d = 1;
						j.totalCount += g;
						e.onLoad();
						j.each(function(a) {
							i = a.dirty;
							a.set("__rowNum", d++);
							if (!i) {
								a.commit()
							}
						})
					}
				}
			}
		}
	},
	check : function(n, j, k, g, e) {
		var h, m, l, f = 0;
		if (j) {
			h = true
		} else {
			h = false
		}
		m = Wb.getSelNode(n);
		if (!m || g) {
			m = n.getRootNode()
		}
		function d(b) {
			l = b.get("checked");
			if (l !== undefined && l !== null && l != h) {
				b.set("checked", h);
				b.commit();
				n.fireEvent("checkchange", b, h)
			}
			b.eachChild(function(i) {
				a(i)
			});
			f--;
			if (f == 0 && e) {
				e()
			}
		}
		function a(b) {
			f++;
			if (k) {
				b.expand(false, function() {
					d(b)
				})
			} else {
				d(b)
			}
		}
		a(m)
	},
	commit : function(a) {
		a.each(function(b) {
			if (b.dirty) {
				b.commit()
			}
		})
	}
};